#!/bin/zsh --no-globalrcs --no-rcs
#
# Copies fixture projects into the test bundle directly, so they don't have to
# be added to the Carthage workspace. This avoids confusing Xcode with
# "subprojects" that are actually just originating from a fixture.

if [[ -z "$1" ]]; then
    echo "Error: You must pass a destination directory."
    exit 1
fi

current=$(cd "$(dirname $0)" && pwd)
destination="$1"

for fixture in "carthage-fixtures-ReactiveCocoaLayout-master" "CartfileOnly" "CartfilePrivateOnly" "NoCartfile" "SchemeDiscoverySampleForCarthage-0.2" "Swell-0.5.0" "SampleMultipleSubprojects" "SampleGitSubmodule" "DependencyTest" "WorkspaceWithDependency" "DynamicAndStatic" "WorkspaceWithDependency" "FilterBogusFrameworks" "NoSharedSchemesTest" "CleanupTest" "ModuleStableBuiltWithSwift5.1.2" "NonModuleStableBuiltWithSwift5.1.2"
do
    rm -Rf "$destination/__MACOSX"
    rm -Rf "$destination/$fixture"
	unzip -q -d "$destination" "$current/../Tests/CarthageKitTests/fixtures/$fixture"
done

rm -Rf "$destination/SampleMultipleSubprojectsSameOldSameOld"
ditto "$destination/SampleMultipleSubprojects" "$destination/SampleMultipleSubprojectsSameOldSameOld"
